<template>
	<view class="pageStyle">
		<view class="select_value">
			<button  type="default"  class="cus_button" :style="{ backgroundColor: '#31E6E1' }" @click="handleShow">选择角色</button>
		</view>
		<uni-data-picker :localdata="dataSource" popup-title="请选择角色" @change="confirmSelect"
			:map="{text:'name',value:'code'}" ref="picker"></uni-data-picker>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				dataSource: [],
			};
		},
		onLoad(options) {
			this.dataSource = options.roleList ? JSON.parse(options.roleList) : [];
		},
		methods: {
			handleShow() {
				this.$refs.picker.show()
			},
			confirmSelect(e) {
				console.log('e', e);
				let record = e.detail.value[0];
				let curRoleCode = record.value;
				uni.setStorage({
					key: 'curRoleCode',
					data: curRoleCode,
					success() {
						//跳转
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/applications/applications'
							});
						});
					}
				});
			},
		}
	};
</script>
<style lang="scss" scoped>
	.pageStyle {
		width: 100%;
		height: 100%;

		.select_value {
			width: 100%;
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
</style>